package com.ruoyi.web.controller.manage;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.manage.domain.IllegalTemplatePictures;
import com.ruoyi.manage.service.IIllegalTemplatePicturesService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 违法图片模板Controller
 * 
 * @author ruoyi
 * @date 2021-01-27
 */
@RestController
@RequestMapping("/manage/pictures")
public class IllegalTemplatePicturesController extends BaseController
{
    @Autowired
    private IIllegalTemplatePicturesService illegalTemplatePicturesService;

    /**
     * 查询违法图片模板列表
     */
    @PreAuthorize("@ss.hasPermi('manage:pictures:list')")
    @GetMapping("/list")
    public TableDataInfo list(IllegalTemplatePictures illegalTemplatePictures)
    {
        startPage();
        List<IllegalTemplatePictures> list = illegalTemplatePicturesService.selectIllegalTemplatePicturesList(illegalTemplatePictures);
        return getDataTable(list);
    }

    /**
     * 导出违法图片模板列表
     */
    @PreAuthorize("@ss.hasPermi('manage:pictures:export')")
    @Log(title = "违法图片模板", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(IllegalTemplatePictures illegalTemplatePictures)
    {
        List<IllegalTemplatePictures> list = illegalTemplatePicturesService.selectIllegalTemplatePicturesList(illegalTemplatePictures);
        ExcelUtil<IllegalTemplatePictures> util = new ExcelUtil<IllegalTemplatePictures>(IllegalTemplatePictures.class);
        return util.exportExcel(list, "pictures");
    }

    /**
     * 获取违法图片模板详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:pictures:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(illegalTemplatePicturesService.selectIllegalTemplatePicturesById(id));
    }

    /**
     * 新增违法图片模板
     */
    @PreAuthorize("@ss.hasPermi('manage:pictures:add')")
    @Log(title = "违法图片模板", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody IllegalTemplatePictures illegalTemplatePictures)
    {
        return toAjax(illegalTemplatePicturesService.insertIllegalTemplatePictures(illegalTemplatePictures));
    }

    /**
     * 修改违法图片模板
     */
    @PreAuthorize("@ss.hasPermi('manage:pictures:edit')")
    @Log(title = "违法图片模板", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody IllegalTemplatePictures illegalTemplatePictures)
    {
        return toAjax(illegalTemplatePicturesService.updateIllegalTemplatePictures(illegalTemplatePictures));
    }

    /**
     * 删除违法图片模板
     */
    @PreAuthorize("@ss.hasPermi('manage:pictures:remove')")
    @Log(title = "违法图片模板", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(illegalTemplatePicturesService.deleteIllegalTemplatePicturesByIds(ids));
    }
}
